
using CStock;
using System;
using System.Diagnostics;
using NUnit.Framework;
using System.Collections;
using CGraph;
using System.Data;
using System.Reflection;
namespace TestCases.UI.Chart
{
	

	/// <summary>Some simple Tests.</summary>
	/// 
	[TestFixture] 
	public class MultiplePlots : SharePlotTest
	{
       
		[SetUp] 
		public void Init() 
		{
            
		}
        [Test]
        public void A_CandlePlot()
        {
            DataTable dt = GetDataFromXML();

            object o = chartWindow.Charts[0];

            //first
            ChartControl  c = chartWindow.Charts[0] as ChartControl ;
            ChartControlsHelper.Test_CandlePlot(c, dt);
                       
            chartWindow.ShowDialog();


        }

        [Test]
        public void Bollinger_Volume_Old()
        {
            ResetChartWindow();
            DataTable dt = GetDataFromXML();

            object o = chartWindow.Charts[0];


            
            chartWindow.Test_MultiplePlot(dt);
            chartWindow.ShowDialog();



        }

        [Test]
        public void TwoCharts()
        {
            DataTable dt = GetDataFromXML();


            object o = chartWindow.Charts[0];

            //first
            ChartControl  c = chartWindow.Charts[0] as ChartControl ;
            ChartControlsHelper.Test_PlotThreeCharts(c, dt);

            //second
            
            c = chartWindow.Charts[1] as ChartControl ;
            ChartControlsHelper.Test_PlotThreeCharts(c, dt);

            chartWindow.ShowDialog();



        }
        [Test]
        public void SecondChartEmpty()
        {
            DataTable dt = GetDataFromXML();


            object o = chartWindow.Charts[0];

            //first
            ChartControl  c = o as ChartControl ;
            ChartControlsHelper.Test_CandlePlot(c, dt);
              
            
            chartWindow.Charts.Add(c);

            //second
            
            //Plot(false);
            chartWindow.ShowDialog();


        }

        private DataTable GetDataFromXML()
        {
            // obtain stock information from xml file
            DataSet ds = new DataSet();
            System.IO.Stream file =
                Assembly.GetExecutingAssembly().GetManifestResourceStream("TestCases.resources.CandleStickData.xml");
            ds.ReadXml(file, System.Data.XmlReadMode.ReadSchema);
            DataTable dt = ds.Tables[0];
            DataView dv = new DataView(dt);
            return dt;

        }
        [Test]
        public void CandlePlot_Bollinger()
        {

            DataTable dt = GetDataFromXML();
            //show


            object o = chartWindow.Charts[0];
            ChartControl  c = o as ChartControl ;
            chartWindow.Charts.Add(c);
            ChartControlsHelper.Test_CandlePlot(c, dt);
             
            

            chartWindow.ShowDialog();




        }
        [Test]
        public void CandlePlot_Bollinger_Double()
        {

            DataTable dt = GetDataFromXML();
            //show


            object o = chartWindow.Charts[0];
            ChartControl  c = o as ChartControl ;
            ChartControlsHelper.Test_CandlePlot(c, dt);
            chartWindow.ShowDialog();




        }
        [Test]
        public void CandlePlot_Bollinger_Old_tiny()
        {

            DataTable dt = new DataTable();

            DataColumn dc = new DataColumn("Open", typeof(double));
            dt.Columns.Add(dc);
            dc = new DataColumn("Low", typeof(double));
            dt.Columns.Add(dc);
            dc = new DataColumn("High", typeof(double));
            dt.Columns.Add(dc);
            dc = new DataColumn("Close", typeof(double));
            dt.Columns.Add(dc);
            dc = new DataColumn("AdjClose", typeof(double));
            dt.Columns.Add(dc);
            dc = new DataColumn("Volume", typeof(long));
            dt.Columns.Add(dc);
            dc = new DataColumn("Date", typeof(DateTime));
            dt.Columns.Add(dc);
            DataRow newRow = dt.NewRow();

            DateTime dateT = DateTime.Now;
            for (int i = 0; i < 15; i++)
            {
                newRow = dt.NewRow();
                newRow[0] = 5F + CUtil.RandomGenerator.Random(1, 100) / 100;
                newRow[1] = 4F + CUtil.RandomGenerator.Random(1, 100) / 100;
                newRow[2] = 6F + CUtil.RandomGenerator.Random(1, 100) / 100;
                newRow[3] = 4.5F + CUtil.RandomGenerator.Random(1, 100) / 100;
                newRow[4] = 4.8F + CUtil.RandomGenerator.Random(1, 100) / 100;

                newRow[5] = 2000;
                newRow[6] = DateTime.Now.AddDays(1);
                dt.Rows.Add(newRow);
            }







            //show


            //DataTable dt = GetDataFromXML();
            //show

            object o = chartWindow.Charts[0];
            ChartControl  c = o as ChartControl ;
            chartWindow.Charts.Add(c);
            ChartControlsHelper.Test_CandlePlot(c, dt);
            chartWindow.ShowDialog();



        }

       
	}
	
}